home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue52 / HTML / Code / AppServer / mleSMLContainer.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1999-10-24  |  1.9 KB  |  87 lines

  1. unit mleSMLContainer;
  2.  
  3. interface
  4.  
  5. uses
  6.   Classes, DBTables, mleCommon, mleDataBindings, mleObjectCache, usXMLDoc;
  7.  
  8. type
  9.   TSMLContainer = class
  10.   private
  11.     FHTML: TStrings;
  12.     FSML: string;
  13.     FObjectCache: TObjectCache;
  14.     FDatabase: TDatabase;
  15.     FVariables: TStrings;
  16.     FScripts: TStrings;
  17.     FDataBindings: TDataBindings;
  18.   protected
  19.     BaseElement: TusXMLElement;
  20.     Parser: TusXMLParser;
  21.     procedure SetSML(aValue: string);
  22.   public
  23.     constructor Create(aPacket: TInfoPacket);
  24.     destructor Destroy; override;
  25.     procedure Resolve;
  26.  
  27.     property Database: TDatabase read FDatabase;
  28.     property DataBindings: TDataBindings read FDataBindings;
  29.     property HTML: TStrings read FHTML;
  30.     property ObjectCache: TObjectCache read FObjectCache;
  31.     property Scripts: TStrings read FScripts;
  32.     property SML: string read FSML write SetSML;
  33.     property Variables: TStrings read FVariables;
  34.   end;
  35.  
  36. implementation
  37.  
  38. uses
  39.   mleTagResolvers;
  40.  
  41. { TSMLContainer }
  42.  
  43. constructor TSMLContainer.Create(aPacket: TInfoPacket);
  44. begin
  45.   inherited Create;
  46.   FDatabase := aPacket.Database;
  47.   FVariables := aPacket.Variables;
  48.   FObjectCache := TObjectCache.Create;
  49.   Parser := TusXMLParser.Create;
  50.   FHTML := TStringList.Create;
  51.   FScripts := TStringList.Create;
  52.   FDataBindings := TDataBindings.Create;
  53. end;
  54.  
  55. destructor TSMLContainer.Destroy;
  56. begin
  57.   FDataBindings.Free;
  58.   FScripts.Free;
  59.   FObjectCache.Free;
  60.   FHTML.Free;
  61.   Parser.Free;
  62.   inherited;
  63. end;
  64.  
  65. procedure TSMLContainer.Resolve;
  66. begin
  67.   with TSMLTagResolver.Create(Self, nil, BaseElement) do
  68.     try
  69.       Setup;
  70.       Resolve;
  71.       Self.HTML.Text := GetHTML;
  72.     finally
  73.       Free;
  74.     end;
  75. end;
  76.  
  77. procedure TSMLContainer.SetSML(aValue: string);
  78. begin
  79.   if aValue <> FSML then
  80.   begin
  81.     Parser.LoadXML(aValue);
  82.     BaseElement := Parser.Document.Root;
  83.   end;
  84. end;
  85.  
  86. end.
  87.